package com.iris.app.deadline;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.iris.app.deadline.vo.FileInfo;

public class DS6PDF extends HttpServlet {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /**
     * The doGet method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to get.
     *
     * @param request the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException if an error occurred
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String [] fileName = {"C0-DS 6上市产品培训-预售手册.pdf","C1-DS 6上市产品培训-市场课件.pdf",
                "C2-DS 6上市产品培训-产品课件.pdf","C3-DS 6上市产品培训-竞品课件.pdf",
                "DS 6 培训挂图更新.pdf","DS 6异议解决话术手册.pdf","DS 6上市产品培训_导购手册1011.pdf" };
        String [] downPath = {"yushoushouce.pdf","shichangkejian.pdf",
                "chanpinkejian.pdf","jingpinkejian.pdf",
                "guatugengxin.pdf","huashushouce.pdf","ds6daogoushouce.pdf" };
        response.setContentType("text/html");
        response.setCharacterEncoding("utf-8");

        PrintWriter out = response.getWriter();

        Gson gson = new Gson();

        List<FileInfo> list = new ArrayList<FileInfo>();


        for(int i = 0 ; i < fileName.length;i++){
            FileInfo first = new FileInfo(fileName[i],"1",downPath[i]);
            list.add(first);
        }
        String json = gson.toJson(list);
        out.write(json);
    }

    /**
     * The doPost method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to post.
     *
     * @param request the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException if an error occurred
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }

}
